program DeleteFrEnd;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  pelement = ^element;
  element = record
    value: integer;
    next: pelement;
  end;

function DeleteFromEnd (var head: pelement): integer;
var
  current, tmp: pelement;
begin
  if (head <> nil) then
  begin
    current:=head;
    while(current^.next <> nil) do
    begin
      tmp:=current;
      current:=current^.next;
    end;
    DeleteFromEnd:=current^.value;
    tmp^.next:=nil;
    Dispose(current);
  end;
end;

procedure Add (var head: pelement; num: integer);
var
  tmp: pelement;
begin
  tmp:=head;
  new(head);
  head^.next:=tmp;
  head^.value:=num;
end;

procedure AddToEnd (var head: pelement; num: Integer);
var
  current: pelement;
begin
  if (head <> nil) then
  begin
    current:=head;
    while (current^.next <> nil) do
    begin
      current:=current^.next;
    end;
    New(current^.next);
    current^.next^.value:=num;
    current^.next^.next:=nil;
  end else begin
    Add(head, num);
  end;
end;

procedure PrintList (head: pelement);
var
  current: pelement;
begin
  current:=head;
  while (current <> nil) do
  begin
    writeln(current^.value);
    current:=current^.next;
  end;
end;

var
  head: pelement;
  fin: TextFile;
  n, i, k: integer;

begin
  AssignFile(fin,'input.txt');
  Reset(fin);
  Read(fin, n);
  if n > 0 then
  begin
    for i:=1 to n do
    begin
      read(fin, k);
      AddToEnd(head, k);
    end;
  end;
  DeleteFromEnd(head);
  PrintList(head);
  readln;
  CloseFile(fin);
end.
